package net.jalbum.filters.arty.effects;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.util.Map;

/**
 *
 * @author Sarah Schölzel
 */
public class RainflowerFilter extends ArtySupport {

    public RainflowerFilter() {
    }

    @Override
    public String getName() {
        return "Rainflower";
    }

    @Override
    public String getDescription() {
        return "effect like the Brannin filter in Instagram, but darker";
    }

    @Override
    public BufferedImage filter(BufferedImage bi, Map map) {
        return filter(bi);
    }

    @Override
    public BufferedImage filter(BufferedImage bi) {
        bi = super.filter(bi);

        //graystyle
        BufferedImage tmp = getGrayScale(bi);

        //saturation = -30
        bi = applySaturation(bi, -30);

        //blending Mode Overlay, 70%
        Graphics2D g2 = bi.createGraphics();
        g2.drawImage(bi, 0, 0, null);

        g2.setComposite(BlendComposite.getInstance(BlendComposite.BlendingMode.OVERLAY, 0.7f));
        g2.drawImage(tmp, 0, 0, bi.getWidth(), bi.getHeight(), null);
        g2.dispose();

        // brightness and contrast
        BufferedImage dstImg = applyBrightnessAndContrast(bi, -10, 20);

        //blending mode Multiply, 80%
        Graphics2D g = dstImg.createGraphics();
        g.drawImage(dstImg, 0, 0, null);

        g.setComposite(BlendComposite.getInstance(BlendComposite.BlendingMode.MULTIPLY, 0.8f));
        g.drawImage(dstImg, 0, 0, bi.getWidth(), bi.getHeight(), null);
        g.dispose();

        //saturation
        dstImg = applySaturation(dstImg, 30);

        return dstImg;
    }
}
